/*
OpenMVL Matrix Vector Library
Copyright (c) 2009 FluidInteractive (R)
 
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising
from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
 
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
 
Written by: Nicola Candussi <nicola@fluidinteractive.com>
*/

//type_traits.hpp

#ifndef MVL_META_TYPE_TRAITS_HPP
#define MVL_META_TYPE_TRAITS_HPP

#include "meta.hpp"

namespace mvl {

namespace meta {

//metafunction to check convertibility from T to U
template<typename T, typename U>
struct is_convertible 
{
private:
    typedef char small;
    class big { char dummy[2]; };
    static small test(const U&);
    static big test(...);
    static T makeT();

public:
    typedef bool_<sizeof(test(makeT())) == sizeof(small)> type;
};

//is const
template<typename T> struct is_const : bool_<false> {};
template<typename T> struct is_const<const T> : bool_<true> {};  

//is_integer
template<typename T> struct is_integer : bool_<false> {};
template<> struct is_integer<char> : bool_<true> {};
template<> struct is_integer<unsigned char> : bool_<true> {};
template<> struct is_integer<short> : bool_<true> {};
template<> struct is_integer<unsigned short> : bool_<true> {};
template<> struct is_integer<int> : bool_<true> {};
template<> struct is_integer<unsigned int> : bool_<true> {};
template<> struct is_integer<long> : bool_<true> {};
template<> struct is_integer<unsigned long> : bool_<true> {};
template<> struct is_integer<long long> : bool_<true> {};
template<> struct is_integer<unsigned long long> : bool_<true> {};

//is_floating_point
template<typename T> struct is_floating_point : bool_<false> {};
template<> struct is_floating_point<float> : bool_<true> {};
template<> struct is_floating_point<double> : bool_<true> {};
template<> struct is_floating_point<long double> : bool_<true> {};

} //namespace meta

} //namespace mvl

#endif
